package com.example.app.web.redissession.controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.outstanding.framework.base.TransactionLogger;
import com.outstanding.framework.core.PendingException;
import com.outstanding.framework.core.ResponseDTO;

import static com.outstanding.framework.container.springmvc.WebLogUtils.*;




@Controller
@RequestMapping("/")
public class DemoController {



	

	// 演示http无参数情况
	// 演示http无参数情况，且需要访问session的情况
	@RequestMapping(value = "/set.do")
	public @ResponseBody ResponseDTO setsession(HttpSession session) throws PendingException {

		debug("调用queryx");
		debug("请求的Session ID＝" + session.getId());
		TransactionLogger.debug("调用set");
		session.setAttribute("a", "dsa");
		// 如果只需要回一个成功指令
		return ResponseDTO.creatDTO();

	}

	// 演示http无参数情况
	// 演示http无参数情况，且需要访问session的情况
	@RequestMapping(value = "/get.do")
	public @ResponseBody String get(HttpSession session) throws PendingException {

		debug("调用queryx");
		debug("请求的Session ID＝" + session.getId());
		TransactionLogger.debug("调用get");
		String str = (String) session.getAttribute("a");
		return str;
	}

	
}
